package com.yjhb.android.sbz.tool;

import android.content.Context;

import com.xiqu.sdklibrary.helper.XQADPage;
import com.xiqu.sdklibrary.helper.XQADPageConfig;
import com.xiqu.sdklibrary.helper.XQAdSdk;
import com.yjhb.android.sbz.App;
import com.yjhb.android.sbz.BuildConfig;
import com.yjhb.android.sbz.R;
import com.yjhb.android.sbz.manager.OAIDManager;

/**
 * 创建者 zx
 * 创建时间 2020/9/7 10:41
 */
public class XQTool {
    private static XQTool dyTool;
    private Context context;

    public static void init(Context context) {
        dyTool = new XQTool(context);
    }

    private XQTool(Context context) {
        this.context = context;
        XQAdSdk.init(App.getInstance(), "4322", "wknaojeaq2xya3gp"); //初始化 参数
        XQAdSdk.showLOG(BuildConfig.DEBUG); //是否开启日志
    }

    public static XQTool getInstance() {
        if (dyTool == null) throw new RuntimeException("请初始化XQTool");
        return dyTool;
    }


    public void startList() {
        if (Tool.checkLogin(context)){
            XQADPage.jumpToAD(new XQADPageConfig.Builder(App.userInfo.getId())
                    .pageType(XQADPageConfig.PAGE_AD_LIST)
                    .actionBarBgColor("#ff2c26")
                    .actionBarTitle("嘻趣游戏")
                    .actionBarBackImageRes(R.mipmap.back_w)
                    .msaOAID(OAIDManager.getInstance().getOaid())
                    .build());
        }
    }

    public void startDetailPage(String advert_id) {
        if (Tool.checkLogin(context)){
            XQADPage.jumpToAD(new XQADPageConfig.Builder(App.userInfo.getId())
                    .pageType(XQADPageConfig.PAGE_AD_DETAIL)
                    .actionBarBgColor("#ff2c26")
                    .msaOAID(OAIDManager.getInstance().getOaid())
                    .advertID(advert_id)
                    .build());
        }
    }

}
